package main

import (
	"fmt"
	"net/rpc/jsonrpc"
)

func main() {
	// 1. 用rpc连接服务器 Dial()
	//conn, err := rpc.Dial("tcp", "127.0.0.1:8080")
	conn, err := jsonrpc.Dial("tcp", "127.0.0.1:8080")
	if err != nil {
		fmt.Println("Dial err: ", err)
		return
	}
	defer conn.Close()

	// 2. 调用远程函数
	var reply string //接收函数返回值
	err = conn.Call("server_name.HelloWorld", "CC", &reply)
	if err != nil {
		fmt.Println("conn.Call err: ", err)
		return
	}

	fmt.Println("reply: ", reply)
}
